import { options } from './../../monitor/mynews/XssWhiteList';
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据

export const Auditcolumns: BasicColumn[] = [
  {
    title: '学号',
    align:"center",
    dataIndex: 'code'
  },
  {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '申请时间',
    align:"center",
    dataIndex: 'createDate'
  },
  {
    title: '事件类型',
    align:"center",
    dataIndex: 'eventType',
    customRender:({text}) => {
      return  render.renderDict(text,'att_event_reg_eventType')
    },
  },


  {
    title: '开始时间',
    align:"center",
    dataIndex: 'startTime'
  },
  {
    title: '结束时间',
    align:"center",
    dataIndex: 'endTime'
  },
  {
    title: '最终结果',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) => {
      return  render.renderDict(text,'att_event_reg_status')
    },
  },
  {
    title: '我的审批',
    align:"center",
    dataIndex: 'applyResultResult',
    customRender:({text}) => {
      return  render.renderDict(text,'att_event_reg_status')
    },
  },

  //  {
  //   title: '删除标识',
  //   align:"center",
  //   dataIndex: 'delFlag'
  //  },
];


export const columns: BasicColumn[] = [
  {
    title: '学号',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '事件类型',
    align:"center",
    dataIndex: 'eventType',
    customRender:({text}) => {
       return  render.renderDict(text,'att_event_reg_eventType')
   },
   },
   {
    title: '开始时间',
    align:"center",
    dataIndex: 'startTime'
   },
   {
    title: '结束时间',
    align:"center",
    dataIndex: 'endTime'
   },
  {
    title: '审核结果',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) => {
      return  render.renderDict(text,'att_event_reg_status')
    },
  },

  {
    title: '申请时间',
    align:"center",
    dataIndex: 'createDate'
  },



  //  {
  //   title: '删除标识',
  //   align:"center",
  //   dataIndex: 'delFlag'
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "姓名",
    field: 'name',
    component: 'Input'
    //colProps: {span: 6},
 },
{
    label: "事件类型",
    field: 'eventType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"att_event_reg_eventType",
      stringToNumber: true,
    }
    //colProps: {span: 6},
 },
 /* {
  label: "事件时间",
  field: "time",
  component: 'RangePicker',
  componentProps: {
      valueType: 'Date',
  },
  //colProps: {span: 6},
}, */
 {
    label: "状态",
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"att_event_reg_status",
      stringToNumber: true,
    }
  //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员',
    field: 'personId',
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
      isRadioSelection: true
    },
    dynamicDisabled: ({ values }) => {
      return !values.id;
    },
    show: ({ values }) => {
      return values.isAudit==1;
    },
  },
  {
    label: '类型名称',
    field: 'eventType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"att_event_reg_eventType",
      stringToNumber: true
    },
    dynamicRules: ({model,schema}) => {
        return [
            { required: true, message: '请选择类型!'},
        ];
    },
    dynamicDisabled: ({ values }) => {
      return values.isAudit==1;
    },
  },
  {
    label: '开始时间',
    field: 'startTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicDisabled: ({ values }) => {
      return values.isAudit==1;
    },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicDisabled: ({ values }) => {
      return values.isAudit==1;
    },
  },
  {
    label: '事由',
    field: 'reason',
    component: 'InputTextArea',
  },
  // {
  //   label: '状态',
  //   field: 'status',
  //   component: 'JDictSelectTag',
  //   componentProps:{
  //     dictCode:"att_event_reg_status",
  //     stringToNumber: true
  //   },
  //   defaultValue: 0,
  //   show: false,
  //   dynamicRules: ({model,schema}) => {
  //       return [
  //           { required: true, message: '请选择状态!'},
  //       ];
  //   },
  // },
  {
    label: '状态',
    field: 'status',
    component: 'RadioGroup',
    componentProps:{
      options:[
        {
          label:'通过',
          value:'1'
        },
        {
          label:'不通过',
          value:'2'
        }
      ]
    },
    // defaultValue: '1',
    show: ({values})=>{
      return values.isAudit==1
    },
  },
  {
    label: '意见',
    field: 'resultRemark',
    component: 'InputTextArea',
    show: ({values})=>{
      return values.isAudit==1
    },
  },
  {
    label: '',
    field: 'applyResultId',
    component: 'Input',
    show:false,
  },



  // {
  //   label: '删除标识',
  //   field: 'delFlag',
  //   component: 'Input',
  // },
	// TODO 主键隐藏字段，目前写死为ID
  {
	  label: '',
	  field: 'isAudit',
    defaultValue: 2,
	  component: 'Input',
	  show: false
	},
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  personId: {title: '人员id',order: 0,view: 'number', type: 'number',},
  eventType: {title: '类型名称',order: 1,view: 'cat_tree', type: 'string',pcode: '',},
  startTime: {title: '开始时间',order: 2,view: 'datetime', type: 'string',},
  endTime: {title: '结束时间',order: 3,view: 'datetime', type: 'string',},
  status: {title: '状态',order: 4,view: 'text', type: 'string',},
  delFlag: {title: '删除标识',order: 5,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
